window.addEventListener('load',function(){
    console.log(111);
    // 获取文件路径
    var file=location.href.substring(0,location.href.lastIndexOf('/'))
    var oLog = document.getElementById('log');
    var oName = document.getElementById('name');
    var oPass = document.getElementById('pass');
    var repass = document.getElementById('repass')
    oName.innerHTML = localStorage.userName;
    oPass.innerHTML = localStorage.passWord;
    
    oLog.addEventListener('click',function(){
        var userName = oName.value;
        var passWord = oPass.value;
        var arr = [];
    
        function findArr() {
            for (var userName in localStorage) {
                arr.push(localStorage[userName]);
            }
            return arr;
        }
        var d = findArr();
        console.log(arr);
        if (userName == d[1] && passWord == d[0]) {
            alert('登录成功');
            location.href = file+'/cart.html'
            //fn&&fn();    
        } else if (userName == d[1] && passWord != d[0]) {
            alert('密码错误');
        } else if (userName != d[1]) {
            alert('用户不存在');
        }
    
    })
       
})